package com.hzit.controller;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.hzit.common.entity.R;
import com.hzit.service.ITypeTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wf
 * @since 2023-08-07
 */
@RestController
@RequestMapping("/typeTemplate")
public class TypeTemplateController {
	@Autowired
	private ITypeTemplateService typeTemplateService;

	//1. 根据模板id查询模板对象
	@GetMapping("/findById/{id}")
	public R findById(@PathVariable("id") Long id){
		return R.ok().put("typeTemplate",typeTemplateService.getById(id));
	}

	//2. 根据模板id查询出规格及规格选项列表
	@GetMapping("/findSpecListByTemplateId/{id}")
	public R findSpecListByTemplateId(@PathVariable("id") Long id){
		List<Map> specList = typeTemplateService.findSpecListByTemplateId(id);
		return R.ok().put("specList",specList);
	}
}
